package triePackage;

import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;

public class Trie implements ITrie {

	/**
	 * Startknoten
	 */
	private TrieNode root;
	
 final private IActionAtInsert usedAlgorithm;
	
	Trie(IActionAtInsert usedAlggorithm){
		this.root = new TrieNode(null, null);
		this.usedAlgorithm = usedAlggorithm;
	}

	@Override
	public ITrieReference put(String string, Object value) {
				
		return root.recursiveInsert(new StringIterator(string), value);

	}

	@Override
	public ITrieReference get(String key) {
	
		return root.recursiveLookUp(new StringIterator(key));
	}

	
	public boolean hasKey(String key) {
		
		if (root.recursiveLookUp(new StringIterator(key)) != null)
			return true;
		
		else return false;
		
	}


	@Override
	public ITrieReference insert(String word) {

		return root.recursiveInsert(new StringIterator(word), usedAlgorithm);
	}

	
	public String toString() {
		root.showWords(root.depth);
		
		return "";
	}
}
